<?php
class XlsExport{
	function __construct(){
	}
	function head(){
		return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
			<html xmlns:o="urn:schemas-microsoft-com:office:office"
			xmlns:x="urn:schemas-microsoft-com:office:excel"
			xmlns="http://www.w3.org/TR/REC-html40">
			<head>
			<title></title>
			<meta http-equiv="Content-Type" content="text/html; charset=uft-8" />
			</head>
			<body>		
			';
	}
	function foot(){
		return '
			</body>
			</html>';
	}
	function export($table='',$filename=''){
		/* 解决IE名称乱码 */
		$filename = iconv('UTF-8', 'gb2312', date("YmdHis",time()).'_'.$filename.'.xls');
		/* 丢弃之前所有缓冲区内容 */
 		header("Content-Type:  application/vnd.ms-excel");
		header("Content-Disposition:  attachment;  filename=\"".$filename."\"");
		header("Content-Encoding: uft8");
		header("Pragma:  no-cache");
		header("Accept-Ranges bytes");
		header("Expires:  0");
		echo ( $this->head().iconv('UTF-8', 'gb2312',$table).$this->foot()  );
		exit();
	}
	
	
}
?>